import { defineStore } from "pinia";
import i18n from "../lang";
//写法一
const useUserStore = defineStore("lang", {
  // options
  state: () => ({
    lang: "zh",
  }),
  //方法：同步异步
  actions: {
    changeLang(val) {
      i18n.global.locale.value = val;
      this.lang = val;
    },
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: "lang",
        storage: localStorage,
      },
    ],
  },
});
//写法二
export default useUserStore;
